Skip to main content

2. The Label Stack

   document are to be interpreted as described in RFC 2119 [2].

2. The Label Stack

2.1. Encoding the Label Stack

   The label stack is represented as a sequence of "label stack
   entries".  Each label stack entry is represented by 4 octets.  This
   is shown in Figure 1.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Label
|                Label                  | Exp |S|       TTL     | Stack
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Entry

                    Label:  Label Value, 20 bits
                    Exp:    Experimental Use, 3 bits
                    S:      Bottom of Stack, 1 bit
                    TTL:    Time to Live, 8 bits

                              Figure 1









   The label stack entries appear AFTER the data link layer headers, but
   BEFORE any network layer headers.  The top of the label stack appears
   earliest in the packet, and the bottom appears latest.  The network
   layer packet immediately follows the label stack entry which has the
   S bit set.

   Each label stack entry is broken down into the following fields:

      1. Bottom of Stack (S)

         This bit is set to one for the last entry in the label stack
         (i.e., for the bottom of the stack), and zero for all other
         label stack entries.

      2. Time to Live (TTL)

         This eight-bit field is used to encode a time-to-live value.
         The processing of this field is described in section 2.4.

      3. Experimental Use

         This three-bit field is reserved for experimental use.

      4. Label Value

         This 20-bit field carries the actual value of the Label.

         When a labeled packet is received, the label value at the top
         of the stack is looked up.  As a result of a successful lookup
         one learns:

         a) the next hop to which the packet is to be forwarded;

         b) the operation to be performed on the label stack before
            forwarding; this operation may be to replace the top label
            stack entry with another, or to pop an entry off the label
            stack, or to replace the top label stack entry and then to
            push one or more additional entries on the label stack.

         In addition to learning the next hop and the label stack
         operation, one may also learn the outgoing data link
         encapsulation, and possibly other information which is needed
         in order to properly forward the packet.











         There are several reserved label values:

           i. A value of 0 represents the "IPv4 Explicit NULL Label".
              This label value is only legal at the bottom of the label
              stack.  It indicates that the label stack must be popped,
              and the forwarding of the packet must then be based on the
              IPv4 header.

          ii. A value of 1 represents the "Router Alert Label".  This
              label value is legal anywhere in the label stack except at
              the bottom.  When a received packet contains this label
              value at the top of the label stack, it is delivered to a
              local software module for processing.  The actual
              forwarding of the packet is determined by the label
              beneath it in the stack.  However, if the packet is
              forwarded further, the Router Alert Label should be pushed
              back onto the label stack before forwarding.  The use of
              this label is analogous to the use of the "Router Alert
              Option" in IP packets [5].  Since this label cannot occur
              at the bottom of the stack, it is not associated with a
              particular network layer protocol.

         iii. A value of 2 represents the "IPv6 Explicit NULL Label".
              This label value is only legal at the bottom of the label
              stack.  It indicates that the label stack must be popped,
              and the forwarding of the packet must then be based on the
              IPv6 header.

          iv. A value of 3 represents the "Implicit NULL Label".  This
              is a label that an LSR may assign and distribute, but
              which never actually appears in the encapsulation.  When
              an LSR would otherwise replace the label at the top of the
              stack with a new label, but the new label is "Implicit
              NULL", the LSR will pop the stack instead of doing the
              replacement.  Although this value may never appear in the
              encapsulation, it needs to be specified in the Label
              Distribution Protocol, so a value is reserved.

           v. Values 4-15 are reserved.

2.2. Determining the Network Layer Protocol

   When the last label is popped from a packet's label stack (resulting
   in the stack being emptied), further processing of the packet is
   based on the packet's network layer header.  The LSR which pops the
   last label off the stack must therefore be able to identify the
   packet's network layer protocol.  However, the label stack does not
   contain any field which explicitly identifies the network layer






   protocol.  This means that the identity of the network layer protocol
   must be inferable from the value of the label which is popped from
   the bottom of the stack, possibly along with the contents of the
   network layer header itself.

   Therefore, when the first label is pushed onto a network layer
   packet, either the label must be one which is used ONLY for packets
   of a particular network layer, or the label must be one which is used
   ONLY for a specified set of network layer protocols, where packets of
   the specified network layers can be distinguished by inspection of
   the network layer header.  Furthermore, whenever that label is
   replaced by another label value during a packet's transit, the new
   value must also be one which meets the same criteria.  If these
   conditions are not met, the LSR which pops the last label off a
   packet will not be able to identify the packet's network layer
   protocol.

   Adherence to these conditions does not necessarily enable
   intermediate nodes to identify a packet's network layer protocol.
   Under ordinary conditions, this is not necessary, but there are error
   conditions under which it is desirable.  For instance, if an
   intermediate LSR determines that a labeled packet is undeliverable,
   it may be desirable for that LSR to generate error messages which are
   specific to the packet's network layer.  The only means the
   intermediate LSR has for identifying the network layer is inspection
   of the top label and the network layer header.  So if intermediate
   nodes are to be able to generate protocol-specific error messages for
   labeled packets, all labels in the stack must meet the criteria
   specified above for labels which appear at the bottom of the stack.

   If a packet cannot be forwarded for some reason (e.g., it exceeds the
   data link MTU), and either its network layer protocol cannot be
   identified, or there are no specified protocol-dependent rules for
   handling the error condition, then the packet MUST be silently
   discarded.

2.3. Generating ICMP Messages for Labeled IP Packets

   Section 2.4 and section 3 discuss situations in which it is desirable
   to generate ICMP messages for labeled IP packets.  In order for a
   particular LSR to be able to generate an ICMP packet and have that
   packet sent to the source of the IP packet, two conditions must hold:

      1. it must be possible for that LSR to determine that a particular
         labeled packet is an IP packet;

      2. it must be possible for that LSR to route to the packet's IP
         source address.






   Condition 1 is discussed in section 2.2.  The following two
   subsections discuss condition 2.  However, there will be some cases
   in which condition 2 does not hold at all, and in these cases it will
   not be possible to generate the ICMP message.

2.3.1. Tunneling through a Transit Routing Domain

   Suppose one is using MPLS to "tunnel" through a transit routing
   domain, where the external routes are not leaked into the domain's
   interior routers.  For example, the interior routers may be running
   OSPF, and may only know how to reach destinations within that OSPF
   domain.  The domain might contain several Autonomous System Border
   Routers (ASBRs), which talk BGP to each other.  However, in this
   example the routes from BGP are not distributed into OSPF, and the
   LSRs which are not ASBRs do not run BGP.

   In this example, only an ASBR will know how to route to the source of
   some arbitrary packet.  If an interior router needs to send an ICMP
   message to the source of an IP packet, it will not know how to route
   the ICMP message.

   One solution is to have one or more of the ASBRs inject "default"
   into the IGP.  (N.B.: this does NOT require that there be a "default"
   carried by BGP.)  This would then ensure that any unlabeled packet
   which must leave the domain (such as an ICMP packet) gets sent to a
   router which has full routing information.  The routers with full
   routing information will label the packets before sending them back
   through the transit domain, so the use of default routing within the
   transit domain does not cause any loops.

   This solution only works for packets which have globally unique
   addresses, and for networks in which all the ASBRs have complete
   routing information.  The next subsection describes a solution which
   works when these conditions do not hold.

2.3.2. Tunneling Private Addresses through a Public Backbone

   In some cases where MPLS is used to tunnel through a routing domain,
   it may not be possible to route to the source address of a fragmented
   packet at all.  This would be the case, for example, if the IP
   addresses carried in the packet were private (i.e., not globally
   unique) addresses, and MPLS were being used to tunnel those packets
   through a public backbone.  Default routing to an ASBR will not work
   in this environment.

   In this environment, in order to send an ICMP message to the source
   of a packet, one can copy the label stack from the original packet to
   the ICMP message, and then label switch the ICMP message.  This will






   cause the message to proceed in the direction of the original
   packet's destination, rather than its source.  Unless the message is
   label switched all the way to the destination host, it will end up,
   unlabeled, in a router which does know how to route to the source of
   original packet, at which point the message will be sent in the
   proper direction.

   This technique can be very useful if the ICMP message is a "Time
   Exceeded" message or a "Destination Unreachable because fragmentation
   needed and DF set" message.

   When copying the label stack from the original packet to the ICMP
   message, the label values must be copied exactly, but the TTL values
   in the label stack should be set to the TTL value that is placed in
   the IP header of the ICMP message.  This TTL value should be long
   enough to allow the circuitous route that the ICMP message will need
   to follow.

   Note that if a packet's TTL expiration is due to the presence of a
   routing loop, then if this technique is used, the ICMP message may
   loop as well.  Since an ICMP message is  never sent as a result of
   receiving an ICMP message, and since many implementations throttle
   the rate at which ICMP messages can be generated, this is not
   expected to pose a problem.

2.4. Processing the Time to Live Field

2.4.1. Definitions

   The "incoming TTL" of a labeled packet is defined to be the value of
   the TTL field of the top label stack entry when the packet is
   received.

   The "outgoing TTL" of a labeled packet is defined to be the larger
   of:

      a) one less than the incoming TTL,
      b) zero.

2.4.2. Protocol-independent rules

   If the outgoing TTL of a labeled packet is 0, then the labeled packet
   MUST NOT be further forwarded; nor may the label stack be stripped
   off and the packet forwarded as an unlabeled packet.  The packet's
   lifetime in the network is considered to have expired.









   Depending on the label value in the label stack entry, the packet MAY
   be simply discarded, or it may be passed to the appropriate
   "ordinary" network layer for error processing (e.g., for the
   generation of an ICMP error message, see section 2.3).

   When a labeled packet is forwarded, the TTL field of the label stack
   entry at the top of the label stack MUST be set to the outgoing TTL
   value.

   Note that the outgoing TTL value is a function solely of the incoming
   TTL value, and is independent of whether any labels are pushed or
   popped before forwarding.  There is no significance to the value of
   the TTL field in any label stack entry which is not at the top of the
   stack.

2.4.3. IP-dependent rules

   We define the "IP TTL" field to be the value of the IPv4 TTL field,
   or the value of the IPv6 Hop Limit field, whichever is applicable.

   When an IP packet is first labeled, the TTL field of the label stack
   entry MUST BE set to the value of the IP TTL field.  (If the IP TTL
   field needs to be decremented, as part of the IP processing, it is
   assumed that this has already been done.)

   When a label is popped, and the resulting label stack is empty, then
   the value of the IP TTL field SHOULD BE replaced with the outgoing
   TTL value, as defined above.  In IPv4 this also requires modification
   of the IP header checksum.

   It is recognized that there may be situations where a network
   administration prefers to decrement the IPv4 TTL by one as it
   traverses an MPLS domain, instead of decrementing the IPv4 TTL by the
   number of LSP hops within the domain.

2.4.4. Translating Between Different Encapsulations

   Sometimes an LSR may receive a labeled packet over, e.g., a label
   switching controlled ATM (LC-ATM) interface [9], and may need to send
   it out over a PPP or LAN link.  Then the incoming packet will not be
   received using the encapsulation specified in this document, but the
   outgoing packet will be sent using the encapsulation specified in
   this document.

   In this case, the value of the "incoming TTL" is determined by the
   procedures used for carrying labeled packets on, e.g., LC-ATM
   interfaces.  TTL processing then proceeds as described above.